

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>TableGen Language Reference &#8212; LLVM 9 documentation</title>
    <link rel="stylesheet" href="../_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="TableGen Language Introduction" href="LangIntro.html" />
    <link rel="prev" title="TableGen BackEnds" href="BackEnds.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="../index.html">
    <img src="../_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="LangIntro.html" title="TableGen Language Introduction"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="BackEnds.html" title="TableGen BackEnds"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">TableGen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">TableGen Language Reference</a></li> 
      </ul>
    </div>


    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <div class="section" id="tablegen-language-reference">
<h1>TableGen Language Reference<a class="headerlink" href="#tablegen-language-reference" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#introduction" id="id1">Introduction</a></p></li>
<li><p><a class="reference internal" href="#notation" id="id2">Notation</a></p></li>
<li><p><a class="reference internal" href="#lexical-analysis" id="id3">Lexical Analysis</a></p></li>
<li><p><a class="reference internal" href="#syntax" id="id4">Syntax</a></p>
<ul>
<li><p><a class="reference internal" href="#classes" id="id5"><code class="docutils literal notranslate"><span class="pre">class</span></code>es</a></p></li>
<li><p><a class="reference internal" href="#declarations" id="id6">Declarations</a></p></li>
<li><p><a class="reference internal" href="#types" id="id7">Types</a></p></li>
<li><p><a class="reference internal" href="#values" id="id8">Values</a></p></li>
<li><p><a class="reference internal" href="#bodies" id="id9">Bodies</a></p></li>
<li><p><a class="reference internal" href="#def" id="id10"><code class="docutils literal notranslate"><span class="pre">def</span></code></a></p></li>
<li><p><a class="reference internal" href="#defm" id="id11"><code class="docutils literal notranslate"><span class="pre">defm</span></code></a></p></li>
<li><p><a class="reference internal" href="#defset" id="id12"><code class="docutils literal notranslate"><span class="pre">defset</span></code></a></p></li>
<li><p><a class="reference internal" href="#foreach" id="id13"><code class="docutils literal notranslate"><span class="pre">foreach</span></code></a></p></li>
<li><p><a class="reference internal" href="#top-level-let" id="id14">Top-Level <code class="docutils literal notranslate"><span class="pre">let</span></code></a></p></li>
<li><p><a class="reference internal" href="#multiclass" id="id15"><code class="docutils literal notranslate"><span class="pre">multiclass</span></code></a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#preprocessing-support" id="id16">Preprocessing Support</a></p></li>
</ul>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>This document is extremely rough. If you find something lacking, please
fix it, file a documentation bug, or ask about it on llvm-dev.</p>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>This document is meant to be a normative spec about the TableGen language
in and of itself (i.e. how to understand a given construct in terms of how
it affects the final set of records represented by the TableGen file). If
you are unsure if this document is really what you are looking for, please
read the <a class="reference internal" href="index.html"><span class="doc">introduction to TableGen</span></a> first.</p>
</div>
<div class="section" id="notation">
<h2><a class="toc-backref" href="#id2">Notation</a><a class="headerlink" href="#notation" title="Permalink to this headline">¶</a></h2>
<p>The lexical and syntax notation used here is intended to imitate
<a class="reference external" href="http://docs.python.org/py3k/reference/introduction.html#notation">Python’s</a>. In particular, for lexical definitions, the productions
operate at the character level and there is no implied whitespace between
elements. The syntax definitions operate at the token level, so there is
implied whitespace between tokens.</p>
</div>
<div class="section" id="lexical-analysis">
<h2><a class="toc-backref" href="#id3">Lexical Analysis</a><a class="headerlink" href="#lexical-analysis" title="Permalink to this headline">¶</a></h2>
<p>TableGen supports BCPL (<code class="docutils literal notranslate"><span class="pre">//</span> <span class="pre">...</span></code>) and nestable C-style (<code class="docutils literal notranslate"><span class="pre">/*</span> <span class="pre">...</span> <span class="pre">*/</span></code>)
comments.  TableGen also provides simple <a class="reference internal" href="#preprocessing-support">Preprocessing Support</a>.</p>
<p>The following is a listing of the basic punctuation tokens:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>- + [ ] { } ( ) &lt; &gt; : ; .  = ? #
</pre></div>
</div>
<p>Numeric literals take one of the following forms:</p>
<pre>
<strong id="grammar-token-TokInteger"><span id="grammar-token-tokinteger"></span>TokInteger    </strong> ::=  <a class="reference internal" href="#grammar-token-DecimalInteger"><code class="xref docutils literal notranslate"><span class="pre">DecimalInteger</span></code></a> | <a class="reference internal" href="#grammar-token-HexInteger"><code class="xref docutils literal notranslate"><span class="pre">HexInteger</span></code></a> | <a class="reference internal" href="#grammar-token-BinInteger"><code class="xref docutils literal notranslate"><span class="pre">BinInteger</span></code></a>
<strong id="grammar-token-DecimalInteger"><span id="grammar-token-decimalinteger"></span>DecimalInteger</strong> ::=  [&quot;+&quot; | &quot;-&quot;] (&quot;0&quot;...&quot;9&quot;)+
<strong id="grammar-token-HexInteger"><span id="grammar-token-hexinteger"></span>HexInteger    </strong> ::=  &quot;0x&quot; (&quot;0&quot;...&quot;9&quot; | &quot;a&quot;...&quot;f&quot; | &quot;A&quot;...&quot;F&quot;)+
<strong id="grammar-token-BinInteger"><span id="grammar-token-bininteger"></span>BinInteger    </strong> ::=  &quot;0b&quot; (&quot;0&quot; | &quot;1&quot;)+
</pre>
<p>One aspect to note is that the <a class="reference internal" href="#grammar-token-DecimalInteger"><code class="xref std std-token docutils literal notranslate"><span class="pre">DecimalInteger</span></code></a> token <em>includes</em> the
<code class="docutils literal notranslate"><span class="pre">+</span></code> or <code class="docutils literal notranslate"><span class="pre">-</span></code>, as opposed to having <code class="docutils literal notranslate"><span class="pre">+</span></code> and <code class="docutils literal notranslate"><span class="pre">-</span></code> be unary operators as
most languages do.</p>
<p>Also note that <a class="reference internal" href="#grammar-token-BinInteger"><code class="xref std std-token docutils literal notranslate"><span class="pre">BinInteger</span></code></a> creates a value of type <code class="docutils literal notranslate"><span class="pre">bits&lt;n&gt;</span></code>
(where <code class="docutils literal notranslate"><span class="pre">n</span></code> is the number of bits).  This will implicitly convert to
integers when needed.</p>
<p>TableGen has identifier-like tokens:</p>
<pre>
<strong id="grammar-token-ualpha">ualpha       </strong> ::=  &quot;a&quot;...&quot;z&quot; | &quot;A&quot;...&quot;Z&quot; | &quot;_&quot;
<strong id="grammar-token-TokIdentifier"><span id="grammar-token-tokidentifier"></span>TokIdentifier</strong> ::=  (&quot;0&quot;...&quot;9&quot;)* <a class="reference internal" href="#grammar-token-ualpha"><code class="xref docutils literal notranslate"><span class="pre">ualpha</span></code></a> (<a class="reference internal" href="#grammar-token-ualpha"><code class="xref docutils literal notranslate"><span class="pre">ualpha</span></code></a> | &quot;0&quot;...&quot;9&quot;)*
<strong id="grammar-token-TokVarName"><span id="grammar-token-tokvarname"></span>TokVarName   </strong> ::=  &quot;$&quot; <a class="reference internal" href="#grammar-token-ualpha"><code class="xref docutils literal notranslate"><span class="pre">ualpha</span></code></a> (<a class="reference internal" href="#grammar-token-ualpha"><code class="xref docutils literal notranslate"><span class="pre">ualpha</span></code></a> |  &quot;0&quot;...&quot;9&quot;)*
</pre>
<p>Note that unlike most languages, TableGen allows <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref std std-token docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a> to
begin with a number. In case of ambiguity, a token will be interpreted as a
numeric literal rather than an identifier.</p>
<p>TableGen also has two string-like literals:</p>
<pre>
<strong id="grammar-token-TokString"><span id="grammar-token-tokstring"></span>TokString      </strong> ::=  '&quot;' &lt;non-'&quot;' characters and C-like escapes&gt; '&quot;'
<strong id="grammar-token-TokCodeFragment"><span id="grammar-token-tokcodefragment"></span>TokCodeFragment</strong> ::=  &quot;[{&quot; &lt;shortest text not containing &quot;}]&quot;&gt; &quot;}]&quot;
</pre>
<p><a class="reference internal" href="#grammar-token-TokCodeFragment"><code class="xref std std-token docutils literal notranslate"><span class="pre">TokCodeFragment</span></code></a> is essentially a multiline string literal
delimited by <code class="docutils literal notranslate"><span class="pre">[{</span></code> and <code class="docutils literal notranslate"><span class="pre">}]</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The current implementation accepts the following C-like escapes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>\\ \<span class="s1">&#39; </span><span class="se">\&quot;</span><span class="s1"> </span><span class="se">\t</span><span class="s1"> </span><span class="se">\n</span>
</pre></div>
</div>
</div>
<p>TableGen also has the following keywords:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">bit</span>   <span class="n">bits</span>      <span class="k">class</span>   <span class="nc">code</span>         <span class="n">dag</span>
<span class="k">def</span>   <span class="nf">foreach</span>   <span class="n">defm</span>    <span class="n">field</span>        <span class="ow">in</span>
<span class="nb">int</span>   <span class="n">let</span>       <span class="nb">list</span>    <span class="n">multiclass</span>   <span class="n">string</span>
</pre></div>
</div>
<p>TableGen also has “bang operators” which have a
wide variety of meanings:</p>
<pre>
<strong id="grammar-token-BangOperator"><span id="grammar-token-bangoperator"></span>BangOperator</strong> ::=  one of
                 !eq     !if      !head    !tail      !con
                 !add    !shl     !sra     !srl       !and
                 !or     !empty   !subst   !foreach   !strconcat
                 !cast   !listconcat       !size      !foldl
                 !isa    !dag     !le      !lt        !ge
                 !gt     !ne      !mul     !listsplat
</pre>
<p>TableGen also has !cond operator that needs a slightly different
syntax compared to other “bang operators”:</p>
<pre>
<strong id="grammar-token-CondOperator"><span id="grammar-token-condoperator"></span>CondOperator</strong> ::=  !cond
</pre>
</div>
<div class="section" id="syntax">
<h2><a class="toc-backref" href="#id4">Syntax</a><a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2>
<p>TableGen has an <code class="docutils literal notranslate"><span class="pre">include</span></code> mechanism. It does not play a role in the
syntax per se, since it is lexically replaced with the contents of the
included file.</p>
<pre>
<strong id="grammar-token-IncludeDirective"><span id="grammar-token-includedirective"></span>IncludeDirective</strong> ::=  &quot;include&quot; <a class="reference internal" href="#grammar-token-TokString"><code class="xref docutils literal notranslate"><span class="pre">TokString</span></code></a>
</pre>
<p>TableGen’s top-level production consists of “objects”.</p>
<pre>
<strong id="grammar-token-TableGenFile"><span id="grammar-token-tablegenfile"></span>TableGenFile</strong> ::=  <a class="reference internal" href="#grammar-token-Object"><code class="xref docutils literal notranslate"><span class="pre">Object</span></code></a>*
<strong id="grammar-token-Object"><span id="grammar-token-object"></span>Object      </strong> ::=  <a class="reference internal" href="#grammar-token-Class"><code class="xref docutils literal notranslate"><span class="pre">Class</span></code></a> | <a class="reference internal" href="#grammar-token-Def"><code class="xref docutils literal notranslate"><span class="pre">Def</span></code></a> | <a class="reference internal" href="#grammar-token-Defm"><code class="xref docutils literal notranslate"><span class="pre">Defm</span></code></a> | <a class="reference internal" href="#grammar-token-Defset"><code class="xref docutils literal notranslate"><span class="pre">Defset</span></code></a> | <a class="reference internal" href="#grammar-token-Let"><code class="xref docutils literal notranslate"><span class="pre">Let</span></code></a> | <a class="reference internal" href="#grammar-token-MultiClass"><code class="xref docutils literal notranslate"><span class="pre">MultiClass</span></code></a> |
</pre>
<div class="section" id="classes">
<h3><a class="toc-backref" href="#id5"><code class="docutils literal notranslate"><span class="pre">class</span></code>es</a><a class="headerlink" href="#classes" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Class"><span id="grammar-token-class"></span>Class          </strong> ::=  &quot;class&quot; <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a> [<a class="reference internal" href="#grammar-token-TemplateArgList"><code class="xref docutils literal notranslate"><span class="pre">TemplateArgList</span></code></a>] <a class="reference internal" href="#grammar-token-ObjectBody"><code class="xref docutils literal notranslate"><span class="pre">ObjectBody</span></code></a>
<strong id="grammar-token-TemplateArgList"><span id="grammar-token-templatearglist"></span>TemplateArgList</strong> ::=  &quot;&lt;&quot; <a class="reference internal" href="#grammar-token-Declaration"><code class="xref docutils literal notranslate"><span class="pre">Declaration</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-Declaration"><code class="xref docutils literal notranslate"><span class="pre">Declaration</span></code></a>)* &quot;&gt;&quot;
</pre>
<p>A <code class="docutils literal notranslate"><span class="pre">class</span></code> declaration creates a record which other records can inherit
from. A class can be parametrized by a list of “template arguments”, whose
values can be used in the class body.</p>
<p>A given class can only be defined once. A <code class="docutils literal notranslate"><span class="pre">class</span></code> declaration is
considered to define the class if any of the following is true:</p>
<ol class="arabic simple">
<li><p>The <a class="reference internal" href="#grammar-token-TemplateArgList"><code class="xref std std-token docutils literal notranslate"><span class="pre">TemplateArgList</span></code></a> is present.</p></li>
<li><p>The <a class="reference internal" href="#grammar-token-Body"><code class="xref std std-token docutils literal notranslate"><span class="pre">Body</span></code></a> in the <a class="reference internal" href="#grammar-token-ObjectBody"><code class="xref std std-token docutils literal notranslate"><span class="pre">ObjectBody</span></code></a> is present and is not empty.</p></li>
<li><p>The <a class="reference internal" href="#grammar-token-BaseClassList"><code class="xref std std-token docutils literal notranslate"><span class="pre">BaseClassList</span></code></a> in the <a class="reference internal" href="#grammar-token-ObjectBody"><code class="xref std std-token docutils literal notranslate"><span class="pre">ObjectBody</span></code></a> is present.</p></li>
</ol>
<p>You can declare an empty class by giving an empty <a class="reference internal" href="#grammar-token-TemplateArgList"><code class="xref std std-token docutils literal notranslate"><span class="pre">TemplateArgList</span></code></a>
and an empty <a class="reference internal" href="#grammar-token-ObjectBody"><code class="xref std std-token docutils literal notranslate"><span class="pre">ObjectBody</span></code></a>. This can serve as a restricted form of
forward declaration: note that records deriving from the forward-declared
class will inherit no fields from it since the record expansion is done
when the record is parsed.</p>
<p>Every class has an implicit template argument called <code class="docutils literal notranslate"><span class="pre">NAME</span></code>, which is set
to the name of the instantiating <code class="docutils literal notranslate"><span class="pre">def</span></code> or <code class="docutils literal notranslate"><span class="pre">defm</span></code>. The result is undefined
if the class is instantiated by an anonymous record.</p>
</div>
<div class="section" id="declarations">
<h3><a class="toc-backref" href="#id6">Declarations</a><a class="headerlink" href="#declarations" title="Permalink to this headline">¶</a></h3>
<p>The declaration syntax is pretty much what you would expect as a C++
programmer.</p>
<pre>
<strong id="grammar-token-Declaration"><span id="grammar-token-declaration"></span>Declaration</strong> ::=  <a class="reference internal" href="#grammar-token-Type"><code class="xref docutils literal notranslate"><span class="pre">Type</span></code></a> <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a> [&quot;=&quot; <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a>]
</pre>
<p>It assigns the value to the identifier.</p>
</div>
<div class="section" id="types">
<h3><a class="toc-backref" href="#id7">Types</a><a class="headerlink" href="#types" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Type"><span id="grammar-token-type"></span>Type   </strong> ::=  &quot;string&quot; | &quot;code&quot; | &quot;bit&quot; | &quot;int&quot; | &quot;dag&quot;
            | &quot;bits&quot; &quot;&lt;&quot; <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref docutils literal notranslate"><span class="pre">TokInteger</span></code></a> &quot;&gt;&quot;
            | &quot;list&quot; &quot;&lt;&quot; <a class="reference internal" href="#grammar-token-Type"><code class="xref docutils literal notranslate"><span class="pre">Type</span></code></a> &quot;&gt;&quot;
            | <a class="reference internal" href="#grammar-token-ClassID"><code class="xref docutils literal notranslate"><span class="pre">ClassID</span></code></a>
<strong id="grammar-token-ClassID"><span id="grammar-token-classid"></span>ClassID</strong> ::=  <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a>
</pre>
<p>Both <code class="docutils literal notranslate"><span class="pre">string</span></code> and <code class="docutils literal notranslate"><span class="pre">code</span></code> correspond to the string type; the difference
is purely to indicate programmer intention.</p>
<p>The <a class="reference internal" href="#grammar-token-ClassID"><code class="xref std std-token docutils literal notranslate"><span class="pre">ClassID</span></code></a> must identify a class that has been previously
declared or defined.</p>
</div>
<div class="section" id="values">
<h3><a class="toc-backref" href="#id8">Values</a><a class="headerlink" href="#values" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Value"><span id="grammar-token-value"></span>Value      </strong> ::=  <a class="reference internal" href="#grammar-token--8"><code class="xref docutils literal notranslate"><span class="pre">SimpleValue</span></code></a> <a class="reference internal" href="#grammar-token-ValueSuffix"><code class="xref docutils literal notranslate"><span class="pre">ValueSuffix</span></code></a>*
<strong id="grammar-token-ValueSuffix"><span id="grammar-token-valuesuffix"></span>ValueSuffix</strong> ::=  &quot;{&quot; <a class="reference internal" href="#grammar-token-RangeList"><code class="xref docutils literal notranslate"><span class="pre">RangeList</span></code></a> &quot;}&quot;
                | &quot;[&quot; <a class="reference internal" href="#grammar-token-RangeList"><code class="xref docutils literal notranslate"><span class="pre">RangeList</span></code></a> &quot;]&quot;
                | &quot;.&quot; <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a>
<strong id="grammar-token-RangeList"><span id="grammar-token-rangelist"></span>RangeList  </strong> ::=  <a class="reference internal" href="#grammar-token-RangePiece"><code class="xref docutils literal notranslate"><span class="pre">RangePiece</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-RangePiece"><code class="xref docutils literal notranslate"><span class="pre">RangePiece</span></code></a>)*
<strong id="grammar-token-RangePiece"><span id="grammar-token-rangepiece"></span>RangePiece </strong> ::=  <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref docutils literal notranslate"><span class="pre">TokInteger</span></code></a>
                | <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref docutils literal notranslate"><span class="pre">TokInteger</span></code></a> &quot;-&quot; <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref docutils literal notranslate"><span class="pre">TokInteger</span></code></a>
                | <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref docutils literal notranslate"><span class="pre">TokInteger</span></code></a> <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref docutils literal notranslate"><span class="pre">TokInteger</span></code></a>
</pre>
<p>The peculiar last form of <a class="reference internal" href="#grammar-token-RangePiece"><code class="xref std std-token docutils literal notranslate"><span class="pre">RangePiece</span></code></a> is due to the fact that the
“<code class="docutils literal notranslate"><span class="pre">-</span></code>” is included in the <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref std std-token docutils literal notranslate"><span class="pre">TokInteger</span></code></a>, hence <code class="docutils literal notranslate"><span class="pre">1-5</span></code> gets lexed as
two consecutive <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref std std-token docutils literal notranslate"><span class="pre">TokInteger</span></code></a>’s, with values <code class="docutils literal notranslate"><span class="pre">1</span></code> and <code class="docutils literal notranslate"><span class="pre">-5</span></code>,
instead of “1”, “-“, and “5”.
The <a class="reference internal" href="#grammar-token-RangeList"><code class="xref std std-token docutils literal notranslate"><span class="pre">RangeList</span></code></a> can be thought of as specifying “list slice” in some
contexts.</p>
<p><a class="reference internal" href="#grammar-token--8"><code class="xref std std-token docutils literal notranslate"><span class="pre">SimpleValue</span></code></a> has a number of forms:</p>
<pre>
<strong id="grammar-token-SimpleValue"><span id="grammar-token-simplevalue"></span>SimpleValue</strong> ::=  <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a>
</pre>
<p>The value will be the variable referenced by the identifier. It can be one
of:</p>
<ul>
<li><p>name of a <code class="docutils literal notranslate"><span class="pre">def</span></code>, such as the use of <code class="docutils literal notranslate"><span class="pre">Bar</span></code> in:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">Bar</span> <span class="p">:</span> <span class="n">SomeClass</span> <span class="p">{</span>
  <span class="nb">int</span> <span class="n">X</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">def</span> <span class="nf">Foo</span> <span class="p">{</span>
  <span class="n">SomeClass</span> <span class="n">Baz</span> <span class="o">=</span> <span class="n">Bar</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>value local to a <code class="docutils literal notranslate"><span class="pre">def</span></code>, such as the use of <code class="docutils literal notranslate"><span class="pre">Bar</span></code> in:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">Foo</span> <span class="p">{</span>
  <span class="nb">int</span> <span class="n">Bar</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span>
  <span class="nb">int</span> <span class="n">Baz</span> <span class="o">=</span> <span class="n">Bar</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Values defined in superclasses can be accessed the same way.</p>
</li>
<li><p>a template arg of a <code class="docutils literal notranslate"><span class="pre">class</span></code>, such as the use of <code class="docutils literal notranslate"><span class="pre">Bar</span></code> in:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="nb">int</span> <span class="n">Bar</span><span class="o">&gt;</span> <span class="p">{</span>
  <span class="nb">int</span> <span class="n">Baz</span> <span class="o">=</span> <span class="n">Bar</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>value local to a <code class="docutils literal notranslate"><span class="pre">class</span></code>, such as the use of <code class="docutils literal notranslate"><span class="pre">Bar</span></code> in:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Foo</span> <span class="p">{</span>
  <span class="nb">int</span> <span class="n">Bar</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span>
  <span class="nb">int</span> <span class="n">Baz</span> <span class="o">=</span> <span class="n">Bar</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>a template arg to a <code class="docutils literal notranslate"><span class="pre">multiclass</span></code>, such as the use of <code class="docutils literal notranslate"><span class="pre">Bar</span></code> in:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">multiclass</span> <span class="n">Foo</span><span class="o">&lt;</span><span class="nb">int</span> <span class="n">Bar</span><span class="o">&gt;</span> <span class="p">{</span>
  <span class="k">def</span> <span class="p">:</span> <span class="n">SomeClass</span><span class="o">&lt;</span><span class="n">Bar</span><span class="o">&gt;</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>the iteration variable of a <code class="docutils literal notranslate"><span class="pre">foreach</span></code>, such as the use of <code class="docutils literal notranslate"><span class="pre">i</span></code> in:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">foreach</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">-</span><span class="mi">5</span> <span class="ow">in</span>
<span class="k">def</span> <span class="nf">Foo</span><span class="c1">#i;</span>
</pre></div>
</div>
</li>
<li><p>a variable defined by <code class="docutils literal notranslate"><span class="pre">defset</span></code></p></li>
<li><p>the implicit template argument <code class="docutils literal notranslate"><span class="pre">NAME</span></code> in a <code class="docutils literal notranslate"><span class="pre">class</span></code> or <code class="docutils literal notranslate"><span class="pre">multiclass</span></code></p></li>
</ul>
<pre>
<strong id="grammar-token--0">SimpleValue</strong> ::=  <a class="reference internal" href="#grammar-token-TokInteger"><code class="xref docutils literal notranslate"><span class="pre">TokInteger</span></code></a>
</pre>
<p>This represents the numeric value of the integer.</p>
<pre>
<strong id="grammar-token--1">SimpleValue</strong> ::=  <a class="reference internal" href="#grammar-token-TokString"><code class="xref docutils literal notranslate"><span class="pre">TokString</span></code></a>+
</pre>
<p>Multiple adjacent string literals are concatenated like in C/C++. The value
is the concatenation of the strings.</p>
<pre>
<strong id="grammar-token--2">SimpleValue</strong> ::=  <a class="reference internal" href="#grammar-token-TokCodeFragment"><code class="xref docutils literal notranslate"><span class="pre">TokCodeFragment</span></code></a>
</pre>
<p>The value is the string value of the code fragment.</p>
<pre>
<strong id="grammar-token--3">SimpleValue</strong> ::=  &quot;?&quot;
</pre>
<p><code class="docutils literal notranslate"><span class="pre">?</span></code> represents an “unset” initializer.</p>
<pre>
<strong id="grammar-token--4">SimpleValue</strong> ::=  &quot;{&quot; <a class="reference internal" href="#grammar-token-ValueList"><code class="xref docutils literal notranslate"><span class="pre">ValueList</span></code></a> &quot;}&quot;
<strong id="grammar-token-ValueList"><span id="grammar-token-valuelist"></span>ValueList  </strong> ::=  [<a class="reference internal" href="#grammar-token-ValueListNE"><code class="xref docutils literal notranslate"><span class="pre">ValueListNE</span></code></a>]
<strong id="grammar-token-ValueListNE"><span id="grammar-token-valuelistne"></span>ValueListNE</strong> ::=  <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a>)*
</pre>
<p>This represents a sequence of bits, as would be used to initialize a
<code class="docutils literal notranslate"><span class="pre">bits&lt;n&gt;</span></code> field (where <code class="docutils literal notranslate"><span class="pre">n</span></code> is the number of bits).</p>
<pre>
<strong id="grammar-token--5">SimpleValue</strong> ::=  <a class="reference internal" href="#grammar-token-ClassID"><code class="xref docutils literal notranslate"><span class="pre">ClassID</span></code></a> &quot;&lt;&quot; <a class="reference internal" href="#grammar-token-ValueListNE"><code class="xref docutils literal notranslate"><span class="pre">ValueListNE</span></code></a> &quot;&gt;&quot;
</pre>
<p>This generates a new anonymous record definition (as would be created by an
unnamed <code class="docutils literal notranslate"><span class="pre">def</span></code> inheriting from the given class with the given template
arguments) and the value is the value of that record definition.</p>
<pre>
<strong id="grammar-token--6">SimpleValue</strong> ::=  &quot;[&quot; <a class="reference internal" href="#grammar-token-ValueList"><code class="xref docutils literal notranslate"><span class="pre">ValueList</span></code></a> &quot;]&quot; [&quot;&lt;&quot; <a class="reference internal" href="#grammar-token-Type"><code class="xref docutils literal notranslate"><span class="pre">Type</span></code></a> &quot;&gt;&quot;]
</pre>
<p>A list initializer. The optional <a class="reference internal" href="#grammar-token-Type"><code class="xref std std-token docutils literal notranslate"><span class="pre">Type</span></code></a> can be used to indicate a
specific element type, otherwise the element type will be deduced from the
given values.</p>
<pre>
<strong id="grammar-token--7">SimpleValue</strong> ::=  &quot;(&quot; <a class="reference internal" href="#grammar-token-DagArg"><code class="xref docutils literal notranslate"><span class="pre">DagArg</span></code></a> [<a class="reference internal" href="#grammar-token-DagArgList"><code class="xref docutils literal notranslate"><span class="pre">DagArgList</span></code></a>] &quot;)&quot;
<strong id="grammar-token-DagArgList"><span id="grammar-token-dagarglist"></span>DagArgList </strong> ::=  <a class="reference internal" href="#grammar-token-DagArg"><code class="xref docutils literal notranslate"><span class="pre">DagArg</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-DagArg"><code class="xref docutils literal notranslate"><span class="pre">DagArg</span></code></a>)*
<strong id="grammar-token-DagArg"><span id="grammar-token-dagarg"></span>DagArg     </strong> ::=  <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a> [&quot;:&quot; <a class="reference internal" href="#grammar-token-TokVarName"><code class="xref docutils literal notranslate"><span class="pre">TokVarName</span></code></a>] | <a class="reference internal" href="#grammar-token-TokVarName"><code class="xref docutils literal notranslate"><span class="pre">TokVarName</span></code></a>
</pre>
<p>The initial <a class="reference internal" href="#grammar-token-DagArg"><code class="xref std std-token docutils literal notranslate"><span class="pre">DagArg</span></code></a> is called the “operator” of the dag.</p>
<pre>
<strong id="grammar-token--8">SimpleValue</strong> ::=  <a class="reference internal" href="#grammar-token-BangOperator"><code class="xref docutils literal notranslate"><span class="pre">BangOperator</span></code></a> [&quot;&lt;&quot; <a class="reference internal" href="#grammar-token-Type"><code class="xref docutils literal notranslate"><span class="pre">Type</span></code></a> &quot;&gt;&quot;] &quot;(&quot; <a class="reference internal" href="#grammar-token-ValueListNE"><code class="xref docutils literal notranslate"><span class="pre">ValueListNE</span></code></a> &quot;)&quot;
                | <a class="reference internal" href="#grammar-token-CondOperator"><code class="xref docutils literal notranslate"><span class="pre">CondOperator</span></code></a> &quot;(&quot; <a class="reference internal" href="#grammar-token-CondVal"><code class="xref docutils literal notranslate"><span class="pre">CondVal</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-CondVal"><code class="xref docutils literal notranslate"><span class="pre">CondVal</span></code></a>)* &quot;)&quot;
<strong id="grammar-token-CondVal"><span id="grammar-token-condval"></span>CondVal    </strong> ::=  <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a> &quot;:&quot; <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a>
</pre>
</div>
<div class="section" id="bodies">
<h3><a class="toc-backref" href="#id9">Bodies</a><a class="headerlink" href="#bodies" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-ObjectBody"><span id="grammar-token-objectbody"></span>ObjectBody     </strong> ::=  <a class="reference internal" href="#grammar-token-BaseClassList"><code class="xref docutils literal notranslate"><span class="pre">BaseClassList</span></code></a> <a class="reference internal" href="#grammar-token-Body"><code class="xref docutils literal notranslate"><span class="pre">Body</span></code></a>
<strong id="grammar-token-BaseClassList"><span id="grammar-token-baseclasslist"></span>BaseClassList  </strong> ::=  [&quot;:&quot; <a class="reference internal" href="#grammar-token-BaseClassListNE"><code class="xref docutils literal notranslate"><span class="pre">BaseClassListNE</span></code></a>]
<strong id="grammar-token-BaseClassListNE"><span id="grammar-token-baseclasslistne"></span>BaseClassListNE</strong> ::=  <a class="reference internal" href="#grammar-token-SubClassRef"><code class="xref docutils literal notranslate"><span class="pre">SubClassRef</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-SubClassRef"><code class="xref docutils literal notranslate"><span class="pre">SubClassRef</span></code></a>)*
<strong id="grammar-token-SubClassRef"><span id="grammar-token-subclassref"></span>SubClassRef    </strong> ::=  (<a class="reference internal" href="#grammar-token-ClassID"><code class="xref docutils literal notranslate"><span class="pre">ClassID</span></code></a> | <a class="reference internal" href="#grammar-token-MultiClassID"><code class="xref docutils literal notranslate"><span class="pre">MultiClassID</span></code></a>) [&quot;&lt;&quot; <a class="reference internal" href="#grammar-token-ValueList"><code class="xref docutils literal notranslate"><span class="pre">ValueList</span></code></a> &quot;&gt;&quot;]
<strong id="grammar-token-DefmID"><span id="grammar-token-defmid"></span>DefmID         </strong> ::=  <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a>
</pre>
<p>The version with the <a class="reference internal" href="#grammar-token-MultiClassID"><code class="xref std std-token docutils literal notranslate"><span class="pre">MultiClassID</span></code></a> is only valid in the
<a class="reference internal" href="#grammar-token-BaseClassList"><code class="xref std std-token docutils literal notranslate"><span class="pre">BaseClassList</span></code></a> of a <code class="docutils literal notranslate"><span class="pre">defm</span></code>.
The <a class="reference internal" href="#grammar-token-MultiClassID"><code class="xref std std-token docutils literal notranslate"><span class="pre">MultiClassID</span></code></a> should be the name of a <code class="docutils literal notranslate"><span class="pre">multiclass</span></code>.</p>
<p>It is after parsing the base class list that the “let stack” is applied.</p>
<pre>
<strong id="grammar-token-Body"><span id="grammar-token-body"></span>Body    </strong> ::=  &quot;;&quot; | &quot;{&quot; BodyList &quot;}&quot;
<strong id="grammar-token-BodyList"><span id="grammar-token-bodylist"></span>BodyList</strong> ::=  BodyItem*
<strong id="grammar-token-BodyItem"><span id="grammar-token-bodyitem"></span>BodyItem</strong> ::=  <a class="reference internal" href="#grammar-token-Declaration"><code class="xref docutils literal notranslate"><span class="pre">Declaration</span></code></a> &quot;;&quot;
             | &quot;let&quot; <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a> [ &quot;{&quot; <a class="reference internal" href="#grammar-token-RangeList"><code class="xref docutils literal notranslate"><span class="pre">RangeList</span></code></a> &quot;}&quot; ] &quot;=&quot; <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a> &quot;;&quot;
</pre>
<p>The <code class="docutils literal notranslate"><span class="pre">let</span></code> form allows overriding the value of an inherited field.</p>
</div>
<div class="section" id="def">
<h3><a class="toc-backref" href="#id10"><code class="docutils literal notranslate"><span class="pre">def</span></code></a><a class="headerlink" href="#def" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Def"><span id="grammar-token-def"></span>Def</strong> ::=  &quot;def&quot; [<a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a>] <a class="reference internal" href="#grammar-token-ObjectBody"><code class="xref docutils literal notranslate"><span class="pre">ObjectBody</span></code></a>
</pre>
<p>Defines a record whose name is given by the optional <a class="reference internal" href="#grammar-token-Value"><code class="xref std std-token docutils literal notranslate"><span class="pre">Value</span></code></a>. The value
is parsed in a special mode where global identifiers (records and variables
defined by <code class="docutils literal notranslate"><span class="pre">defset</span></code>) are not recognized, and all unrecognized identifiers
are interpreted as strings.</p>
<p>If no name is given, the record is anonymous. The final name of anonymous
records is undefined, but globally unique.</p>
<p>Special handling occurs if this <code class="docutils literal notranslate"><span class="pre">def</span></code> appears inside a <code class="docutils literal notranslate"><span class="pre">multiclass</span></code> or
a <code class="docutils literal notranslate"><span class="pre">foreach</span></code>.</p>
<p>When a non-anonymous record is defined in a multiclass and the given name
does not contain a reference to the implicit template argument <code class="docutils literal notranslate"><span class="pre">NAME</span></code>, such
a reference will automatically be prepended. That is, the following are
equivalent inside a multiclass:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">Foo</span><span class="p">;</span>
<span class="k">def</span> <span class="nf">NAME</span><span class="c1">#Foo;</span>
</pre></div>
</div>
</div>
<div class="section" id="defm">
<h3><a class="toc-backref" href="#id11"><code class="docutils literal notranslate"><span class="pre">defm</span></code></a><a class="headerlink" href="#defm" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Defm"><span id="grammar-token-defm"></span>Defm</strong> ::=  &quot;defm&quot; [<a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a>] &quot;:&quot; <a class="reference internal" href="#grammar-token-BaseClassListNE"><code class="xref docutils literal notranslate"><span class="pre">BaseClassListNE</span></code></a> &quot;;&quot;
</pre>
<p>The <a class="reference internal" href="#grammar-token-BaseClassList"><code class="xref std std-token docutils literal notranslate"><span class="pre">BaseClassList</span></code></a> is a list of at least one <code class="docutils literal notranslate"><span class="pre">multiclass</span></code> and any
number of <code class="docutils literal notranslate"><span class="pre">class</span></code>’s. The <code class="docutils literal notranslate"><span class="pre">multiclass</span></code>’s must occur before any <code class="docutils literal notranslate"><span class="pre">class</span></code>’s.</p>
<p>Instantiates all records defined in all given <code class="docutils literal notranslate"><span class="pre">multiclass</span></code>’s and adds the
given <code class="docutils literal notranslate"><span class="pre">class</span></code>’s as superclasses.</p>
<p>The name is parsed in the same special mode used by <code class="docutils literal notranslate"><span class="pre">def</span></code>. If the name is
missing, a globally unique string is used instead (but instantiated records
are not considered to be anonymous, unless they were originally defined by an
anonymous <code class="docutils literal notranslate"><span class="pre">def</span></code>) That is, the following have different semantics:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">defm</span> <span class="p">:</span> <span class="n">SomeMultiClass</span><span class="o">&lt;...&gt;</span><span class="p">;</span>    <span class="o">//</span> <span class="n">some</span> <span class="n">globally</span> <span class="n">unique</span> <span class="n">name</span>
<span class="n">defm</span> <span class="s2">&quot;&quot;</span> <span class="p">:</span> <span class="n">SomeMultiClass</span><span class="o">&lt;...&gt;</span><span class="p">;</span> <span class="o">//</span> <span class="n">empty</span> <span class="n">name</span> <span class="n">string</span>
</pre></div>
</div>
<p>When it occurs inside a multiclass, the second variant is equivalent to
<code class="docutils literal notranslate"><span class="pre">defm</span> <span class="pre">NAME</span> <span class="pre">:</span> <span class="pre">...</span></code>. More generally, when <code class="docutils literal notranslate"><span class="pre">defm</span></code> occurs in a multiclass and
its name does not contain a reference to the implicit template argument
<code class="docutils literal notranslate"><span class="pre">NAME</span></code>, such a reference will automatically be prepended. That is, the
following are equivalent inside a multiclass:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">defm</span> <span class="n">Foo</span> <span class="p">:</span> <span class="n">SomeMultiClass</span><span class="o">&lt;...&gt;</span><span class="p">;</span>
<span class="n">defm</span> <span class="n">NAME</span><span class="c1">#Foo : SomeMultiClass&lt;...&gt;;</span>
</pre></div>
</div>
</div>
<div class="section" id="defset">
<h3><a class="toc-backref" href="#id12"><code class="docutils literal notranslate"><span class="pre">defset</span></code></a><a class="headerlink" href="#defset" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Defset"><span id="grammar-token-defset"></span>Defset</strong> ::=  &quot;defset&quot; <a class="reference internal" href="#grammar-token-Type"><code class="xref docutils literal notranslate"><span class="pre">Type</span></code></a> <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a> &quot;=&quot; &quot;{&quot; <a class="reference internal" href="#grammar-token-Object"><code class="xref docutils literal notranslate"><span class="pre">Object</span></code></a>* &quot;}&quot;
</pre>
<p>All records defined inside the braces via <code class="docutils literal notranslate"><span class="pre">def</span></code> and <code class="docutils literal notranslate"><span class="pre">defm</span></code> are collected
in a globally accessible list of the given name (in addition to being added
to the global collection of records as usual). Anonymous records created inside
initializier expressions using the <code class="docutils literal notranslate"><span class="pre">Class&lt;args...&gt;</span></code> syntax are never collected
in a defset.</p>
<p>The given type must be <code class="docutils literal notranslate"><span class="pre">list&lt;A&gt;</span></code>, where <code class="docutils literal notranslate"><span class="pre">A</span></code> is some class. It is an error
to define a record (via <code class="docutils literal notranslate"><span class="pre">def</span></code> or <code class="docutils literal notranslate"><span class="pre">defm</span></code>) inside the braces which doesn’t
derive from <code class="docutils literal notranslate"><span class="pre">A</span></code>.</p>
</div>
<div class="section" id="foreach">
<h3><a class="toc-backref" href="#id13"><code class="docutils literal notranslate"><span class="pre">foreach</span></code></a><a class="headerlink" href="#foreach" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Foreach"><span id="grammar-token-foreach"></span>Foreach           </strong> ::=  &quot;foreach&quot; <a class="reference internal" href="#grammar-token-ForeachDeclaration"><code class="xref docutils literal notranslate"><span class="pre">ForeachDeclaration</span></code></a> &quot;in&quot; &quot;{&quot; <a class="reference internal" href="#grammar-token-Object"><code class="xref docutils literal notranslate"><span class="pre">Object</span></code></a>* &quot;}&quot;
                       | &quot;foreach&quot; <a class="reference internal" href="#grammar-token-ForeachDeclaration"><code class="xref docutils literal notranslate"><span class="pre">ForeachDeclaration</span></code></a> &quot;in&quot; <a class="reference internal" href="#grammar-token-Object"><code class="xref docutils literal notranslate"><span class="pre">Object</span></code></a>
<strong id="grammar-token-ForeachDeclaration"><span id="grammar-token-foreachdeclaration"></span>ForeachDeclaration</strong> ::=  ID &quot;=&quot; ( &quot;{&quot; <a class="reference internal" href="#grammar-token-RangeList"><code class="xref docutils literal notranslate"><span class="pre">RangeList</span></code></a> &quot;}&quot; | <a class="reference internal" href="#grammar-token-RangePiece"><code class="xref docutils literal notranslate"><span class="pre">RangePiece</span></code></a> | <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a> )
</pre>
<p>The value assigned to the variable in the declaration is iterated over and
the object or object list is reevaluated with the variable set at each
iterated value.</p>
<p>Note that the productions involving RangeList and RangePiece have precedence
over the more generic value parsing based on the first token.</p>
</div>
<div class="section" id="top-level-let">
<h3><a class="toc-backref" href="#id14">Top-Level <code class="docutils literal notranslate"><span class="pre">let</span></code></a><a class="headerlink" href="#top-level-let" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-Let"><span id="grammar-token-let"></span>Let    </strong> ::=   &quot;let&quot; <a class="reference internal" href="#grammar-token-LetList"><code class="xref docutils literal notranslate"><span class="pre">LetList</span></code></a> &quot;in&quot; &quot;{&quot; <a class="reference internal" href="#grammar-token-Object"><code class="xref docutils literal notranslate"><span class="pre">Object</span></code></a>* &quot;}&quot;
            | &quot;let&quot; <a class="reference internal" href="#grammar-token-LetList"><code class="xref docutils literal notranslate"><span class="pre">LetList</span></code></a> &quot;in&quot; <a class="reference internal" href="#grammar-token-Object"><code class="xref docutils literal notranslate"><span class="pre">Object</span></code></a>
<strong id="grammar-token-LetList"><span id="grammar-token-letlist"></span>LetList</strong> ::=  <a class="reference internal" href="#grammar-token-LetItem"><code class="xref docutils literal notranslate"><span class="pre">LetItem</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-LetItem"><code class="xref docutils literal notranslate"><span class="pre">LetItem</span></code></a>)*
<strong id="grammar-token-LetItem"><span id="grammar-token-letitem"></span>LetItem</strong> ::=  <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a> [<a class="reference internal" href="#grammar-token-RangeList"><code class="xref docutils literal notranslate"><span class="pre">RangeList</span></code></a>] &quot;=&quot; <a class="reference internal" href="#grammar-token-Value"><code class="xref docutils literal notranslate"><span class="pre">Value</span></code></a>
</pre>
<p>This is effectively equivalent to <code class="docutils literal notranslate"><span class="pre">let</span></code> inside the body of a record
except that it applies to multiple records at a time. The bindings are
applied at the end of parsing the base classes of a record.</p>
</div>
<div class="section" id="multiclass">
<h3><a class="toc-backref" href="#id15"><code class="docutils literal notranslate"><span class="pre">multiclass</span></code></a><a class="headerlink" href="#multiclass" title="Permalink to this headline">¶</a></h3>
<pre>
<strong id="grammar-token-MultiClass"><span id="grammar-token-multiclass"></span>MultiClass        </strong> ::=  &quot;multiclass&quot; <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a> [<a class="reference internal" href="#grammar-token-TemplateArgList"><code class="xref docutils literal notranslate"><span class="pre">TemplateArgList</span></code></a>]
                        [&quot;:&quot; <a class="reference internal" href="#grammar-token-BaseMultiClassList"><code class="xref docutils literal notranslate"><span class="pre">BaseMultiClassList</span></code></a>] &quot;{&quot; <a class="reference internal" href="#grammar-token-MultiClassObject"><code class="xref docutils literal notranslate"><span class="pre">MultiClassObject</span></code></a>+ &quot;}&quot;
<strong id="grammar-token-BaseMultiClassList"><span id="grammar-token-basemulticlasslist"></span>BaseMultiClassList</strong> ::=  <a class="reference internal" href="#grammar-token-MultiClassID"><code class="xref docutils literal notranslate"><span class="pre">MultiClassID</span></code></a> (&quot;,&quot; <a class="reference internal" href="#grammar-token-MultiClassID"><code class="xref docutils literal notranslate"><span class="pre">MultiClassID</span></code></a>)*
<strong id="grammar-token-MultiClassID"><span id="grammar-token-multiclassid"></span>MultiClassID      </strong> ::=  <a class="reference internal" href="#grammar-token-TokIdentifier"><code class="xref docutils literal notranslate"><span class="pre">TokIdentifier</span></code></a>
<strong id="grammar-token-MultiClassObject"><span id="grammar-token-multiclassobject"></span>MultiClassObject  </strong> ::=  <a class="reference internal" href="#grammar-token-Def"><code class="xref docutils literal notranslate"><span class="pre">Def</span></code></a> | <a class="reference internal" href="#grammar-token-Defm"><code class="xref docutils literal notranslate"><span class="pre">Defm</span></code></a> | <a class="reference internal" href="#grammar-token-Let"><code class="xref docutils literal notranslate"><span class="pre">Let</span></code></a> | <a class="reference internal" href="#grammar-token-Foreach"><code class="xref docutils literal notranslate"><span class="pre">Foreach</span></code></a>
</pre>
</div>
</div>
<div class="section" id="preprocessing-support">
<h2><a class="toc-backref" href="#id16">Preprocessing Support</a><a class="headerlink" href="#preprocessing-support" title="Permalink to this headline">¶</a></h2>
<p>TableGen’s embedded preprocessor is only intended for conditional compilation.
It supports the following directives:</p>
<pre>
<strong id="grammar-token-LineBegin"><span id="grammar-token-linebegin"></span>LineBegin                </strong> ::=  ^
<strong id="grammar-token-LineEnd"><span id="grammar-token-lineend"></span>LineEnd                  </strong> ::=  &quot;\n&quot; | &quot;\r&quot; | EOF
<strong id="grammar-token-WhiteSpace"><span id="grammar-token-whitespace"></span>WhiteSpace               </strong> ::=  &quot; &quot; | &quot;\t&quot;
<strong id="grammar-token-CStyleComment"><span id="grammar-token-cstylecomment"></span>CStyleComment            </strong> ::=  &quot;/*&quot; (.* - &quot;*/&quot;) &quot;*/&quot;
<strong id="grammar-token-BCPLComment"><span id="grammar-token-bcplcomment"></span>BCPLComment              </strong> ::=  &quot;//&quot; (.* - <a class="reference internal" href="#grammar-token-LineEnd"><code class="xref docutils literal notranslate"><span class="pre">LineEnd</span></code></a>) <a class="reference internal" href="#grammar-token-LineEnd"><code class="xref docutils literal notranslate"><span class="pre">LineEnd</span></code></a>
<strong id="grammar-token-WhiteSpaceOrCStyleComment"><span id="grammar-token-whitespaceorcstylecomment"></span>WhiteSpaceOrCStyleComment</strong> ::=  <a class="reference internal" href="#grammar-token-WhiteSpace"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpace</span></code></a> | <a class="reference internal" href="#grammar-token-CStyleComment"><code class="xref docutils literal notranslate"><span class="pre">CStyleComment</span></code></a>
<strong id="grammar-token-WhiteSpaceOrAnyComment"><span id="grammar-token-whitespaceoranycomment"></span>WhiteSpaceOrAnyComment   </strong> ::=  <a class="reference internal" href="#grammar-token-WhiteSpace"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpace</span></code></a> | <a class="reference internal" href="#grammar-token-CStyleComment"><code class="xref docutils literal notranslate"><span class="pre">CStyleComment</span></code></a> | <a class="reference internal" href="#grammar-token-BCPLComment"><code class="xref docutils literal notranslate"><span class="pre">BCPLComment</span></code></a>
<strong id="grammar-token-MacroName"><span id="grammar-token-macroname"></span>MacroName                </strong> ::=  <a class="reference internal" href="#grammar-token-ualpha"><code class="xref docutils literal notranslate"><span class="pre">ualpha</span></code></a> (<a class="reference internal" href="#grammar-token-ualpha"><code class="xref docutils literal notranslate"><span class="pre">ualpha</span></code></a> | &quot;0&quot;...&quot;9&quot;)*
<strong id="grammar-token-PrepDefine"><span id="grammar-token-prepdefine"></span>PrepDefine               </strong> ::=  <a class="reference internal" href="#grammar-token-LineBegin"><code class="xref docutils literal notranslate"><span class="pre">LineBegin</span></code></a> (<a class="reference internal" href="#grammar-token-WhiteSpaceOrCStyleComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrCStyleComment</span></code></a>)*
                               &quot;#define&quot; (<a class="reference internal" href="#grammar-token-WhiteSpace"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpace</span></code></a>)+ <a class="reference internal" href="#grammar-token-MacroName"><code class="xref docutils literal notranslate"><span class="pre">MacroName</span></code></a>
                               (<a class="reference internal" href="#grammar-token-WhiteSpaceOrAnyComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrAnyComment</span></code></a>)* <a class="reference internal" href="#grammar-token-LineEnd"><code class="xref docutils literal notranslate"><span class="pre">LineEnd</span></code></a>
<strong id="grammar-token-PrepIfdef"><span id="grammar-token-prepifdef"></span>PrepIfdef                </strong> ::=  <a class="reference internal" href="#grammar-token-LineBegin"><code class="xref docutils literal notranslate"><span class="pre">LineBegin</span></code></a> (<a class="reference internal" href="#grammar-token-WhiteSpaceOrCStyleComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrCStyleComment</span></code></a>)*
                               &quot;#ifdef&quot; (<a class="reference internal" href="#grammar-token-WhiteSpace"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpace</span></code></a>)+ <a class="reference internal" href="#grammar-token-MacroName"><code class="xref docutils literal notranslate"><span class="pre">MacroName</span></code></a>
                               (<a class="reference internal" href="#grammar-token-WhiteSpaceOrAnyComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrAnyComment</span></code></a>)* <a class="reference internal" href="#grammar-token-LineEnd"><code class="xref docutils literal notranslate"><span class="pre">LineEnd</span></code></a>
<strong id="grammar-token-PrepElse"><span id="grammar-token-prepelse"></span>PrepElse                 </strong> ::=  <a class="reference internal" href="#grammar-token-LineBegin"><code class="xref docutils literal notranslate"><span class="pre">LineBegin</span></code></a> (<a class="reference internal" href="#grammar-token-WhiteSpaceOrCStyleComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrCStyleComment</span></code></a>)*
                               &quot;#else&quot; (<a class="reference internal" href="#grammar-token-WhiteSpaceOrAnyComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrAnyComment</span></code></a>)* <a class="reference internal" href="#grammar-token-LineEnd"><code class="xref docutils literal notranslate"><span class="pre">LineEnd</span></code></a>
<strong id="grammar-token-PrepEndif"><span id="grammar-token-prependif"></span>PrepEndif                </strong> ::=  <a class="reference internal" href="#grammar-token-LineBegin"><code class="xref docutils literal notranslate"><span class="pre">LineBegin</span></code></a> (<a class="reference internal" href="#grammar-token-WhiteSpaceOrCStyleComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrCStyleComment</span></code></a>)*
                               &quot;#endif&quot; (<a class="reference internal" href="#grammar-token-WhiteSpaceOrAnyComment"><code class="xref docutils literal notranslate"><span class="pre">WhiteSpaceOrAnyComment</span></code></a>)* <a class="reference internal" href="#grammar-token-LineEnd"><code class="xref docutils literal notranslate"><span class="pre">LineEnd</span></code></a>
<strong id="grammar-token-PrepRegContentException"><span id="grammar-token-prepregcontentexception"></span>PrepRegContentException  </strong> ::=  <a class="reference internal" href="#grammar-token-PrepIfdef"><code class="xref docutils literal notranslate"><span class="pre">PrepIfdef</span></code></a> | <a class="reference internal" href="#grammar-token-PrepElse"><code class="xref docutils literal notranslate"><span class="pre">PrepElse</span></code></a> | <a class="reference internal" href="#grammar-token-PrepEndif"><code class="xref docutils literal notranslate"><span class="pre">PrepEndif</span></code></a> | EOF
<strong id="grammar-token-PrepRegion"><span id="grammar-token-prepregion"></span>PrepRegion               </strong> ::=  .* - <a class="reference internal" href="#grammar-token-PrepRegContentException"><code class="xref docutils literal notranslate"><span class="pre">PrepRegContentException</span></code></a>
                              | <a class="reference internal" href="#grammar-token-PrepIfdef"><code class="xref docutils literal notranslate"><span class="pre">PrepIfdef</span></code></a>
                                (<a class="reference internal" href="#grammar-token-PrepRegion"><code class="xref docutils literal notranslate"><span class="pre">PrepRegion</span></code></a>)*
                                [<a class="reference internal" href="#grammar-token-PrepElse"><code class="xref docutils literal notranslate"><span class="pre">PrepElse</span></code></a>]
                                (<a class="reference internal" href="#grammar-token-PrepRegion"><code class="xref docutils literal notranslate"><span class="pre">PrepRegion</span></code></a>)*
                                <a class="reference internal" href="#grammar-token-PrepEndif"><code class="xref docutils literal notranslate"><span class="pre">PrepEndif</span></code></a>
</pre>
<p><a class="reference internal" href="#grammar-token-PrepRegion"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepRegion</span></code></a> may occur anywhere in a TD file, as long as it matches
the grammar specification.</p>
<p><a class="reference internal" href="#grammar-token-PrepDefine"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepDefine</span></code></a> allows defining a <a class="reference internal" href="#grammar-token-MacroName"><code class="xref std std-token docutils literal notranslate"><span class="pre">MacroName</span></code></a> so that any following
<a class="reference internal" href="#grammar-token-PrepIfdef"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepIfdef</span></code></a> - <a class="reference internal" href="#grammar-token-PrepElse"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepElse</span></code></a> preprocessing region part and
<a class="reference internal" href="#grammar-token-PrepIfdef"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepIfdef</span></code></a> - <a class="reference internal" href="#grammar-token-PrepEndif"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepEndif</span></code></a> preprocessing region
are enabled for TableGen tokens parsing.</p>
<p>A preprocessing region, starting (i.e. having its <a class="reference internal" href="#grammar-token-PrepIfdef"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepIfdef</span></code></a>) in a file,
must end (i.e. have its <a class="reference internal" href="#grammar-token-PrepEndif"><code class="xref std std-token docutils literal notranslate"><span class="pre">PrepEndif</span></code></a>) in the same file.</p>
<p>A <a class="reference internal" href="#grammar-token-MacroName"><code class="xref std std-token docutils literal notranslate"><span class="pre">MacroName</span></code></a> may be defined externally by using <code class="docutils literal notranslate"><span class="pre">{</span> <span class="pre">-D&lt;NAME&gt;</span> <span class="pre">}</span></code>
option of TableGen.</p>
</div>
</div>


            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="LangIntro.html" title="TableGen Language Introduction"
             >next</a> |</li>
        <li class="right" >
          <a href="BackEnds.html" title="TableGen BackEnds"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="index.html" >TableGen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">TableGen Language Reference</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2020, LLVM Project.
      Last updated on 2020-09-20.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
    </div>
  </body>
</html>